package com.briup.ch03;
import java.util.Scanner;

public class Test04 {

    public static void swap(int a,int b)
    {
        System.out.println("交换前：a="+a+";b="+b);
        int t=0;
        t=a;
        a=b;
        b=t;
        System.out.println("交换后：a="+a+";b="+b);
    }
    public static void swap2(int a,int b)
    {
        System.out.println("交换前：a="+a+";b="+b);
        a=a^b;
        b=a^b;
        a=a^b;
        System.out.println("交换后：a="+a+";b="+b);
    }
    public static void main(String[] args) {
        int a=0;
        int b=0;
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入a:");
        a=scanner.nextInt();
        System.out.println("请输入b:");
        b=scanner.nextInt();
        swap(a,b);
        swap2(a,b);
        System.out.println("a:"+a+"b:"+b);
    }
}
